import tkinter as tk
from tkinter import ttk
import tkinterdnd2

import locale

# 设置语言环境为中文
# locale.setlocale(locale.LC_ALL, 'zh_CN.UTF-8')
from app import Menubar
from constant import SYSTEM, BASE_FOLDER, APPLICATION_NAME
from main_frame import MainFrame
from utility import center_window

class PDFeXpress(tkinterdnd2.Tk):
    def __init__(self):
        super().__init__()
        self.title("PDFeXpress")
        self.iconbitmap(BASE_FOLDER / 'data/PDFeXpress.ico')
        self.geometry('1500x1200')

        # 根据缩放比例调整字体大小
        # 设置 Tkinter 缩放比例
        self.tk.call('tk', 'scaling', 3)  # 3.5 对应 350% 缩放

        self.scale_factor = self.winfo_fpixels('1i') / 96  # 获取缩放比例
        self.font_size = int(12 * self.scale_factor)

        self.MainMenu = Menubar(self)
        self.configure(menu=self.MainMenu)
        self.MainFrame = MainFrame(self)
        self.MainFrame.pack(expand=True, fill='both', padx=4, pady=4)

        center_window(self, 128)

    def run(self):
        self.mainloop()

if __name__ == '__main__':
    if SYSTEM == 'Windows':
        import ctypes
        ctypes.windll.shcore.SetProcessDpiAwareness(True)

    app = PDFeXpress()
    app.run()